<?php
/**
 * 价格表类

 * @author jroam
 *
 */
class priceAction extends Action{
	
	/**
	 * 保存每个时间段的价格设置
	 */
	function saveroomprice(){
		$pid=$_REQUEST["thispid"];//价格表的ID
		$zv=$_REQUEST["zv"];//更改后的价格值
		$PMID=$_REQUEST["PMID"];
		$MenuId=$_REQUEST["MenuId"];
		$hid=$_REQUEST["hid"];//客栈ID
		
		
		if(!is_numeric($pid)) die("传入id值不对");
		if($zv=="") die("内容不能不空");
		
		$mr=M("price");
		$data["price19"]=$zv;
		
		if($mr->where("price0=".$pid)->save($data)){
			//更新最低价
			$umin=A("hotelroom");
			$umin->updateroomminprice($hid);
			
			
			alert("", 0, "修改成功");

			gourl(U("/hotelroom/listroom")."/hid/".$hid."/pid/".$pid."/MenuId/".$MenuId."/PMID/".$PMID,1);
		}else{
			
			alert("", 1, "修改失败");
		}
	
	}
	
	/**
	 * 管理时间段的页面，可以添加修改
	 */
	function timeduanhtm(){
		$hid=$_REQUEST["hid"];//客栈ID
		$action=$_REQUEST["action"];//操作类型
		$pid=$_REQUEST["pid"];//价格表id
		if($pid=="") $pid="0";
		if(!is_numeric($pid)) die("价格类型不对");
		
		
		if(!is_numeric($hid)) die("传入参数不正确");
		$mr=M("price");
		//获取祝栈信息
		$sql="select * from ".DQ."hotel where hotel0=".$hid;
		$hotelrs=$mr->query($sql); 
		
		
		//获取所有的字间段记录
		$sql="select * from ".DQ."price where price4=$hid and price3=612 order by price18 desc";
		$pricers=$mr->query($sql);
		
				
		if($pricers) $this->assign("pricers",$pricers);
		
		$this->assign("hid",$hid);
		$this->assign("pid",$pid);
		$this->assign("hotelrs",$hotelrs[0]);
		$this->display();
		
		
	}
	
	
	
	/**
	 * 保存房型修改后的价格值
	 */
	function saveroomprice22(){
		$pid=$_REQUEST["thisindex"];//修改的价格表id
		$rid=$_REQUEST["rid"];//房型的id值
		$MenuId=$_REQUEST["MenuId"];
		$PMID=$_REQUEST["PMID"];
		
		if(!is_numeric($rid)){
			alert("", 1, "传入参数不正确1");
			die;
		}
		if($pid=="") $pid=0;
		if(!is_numeric($pid)) {
			alert("", 1, "传入参数不正确2");
			die;
		}
		
		$data["price1"]=$_REQUEST["chufaname"];
		$data["price13"]=strtotime($_REQUEST["starttime"]);
		$data["price14"]=strtotime($_REQUEST["overtime"]);
		$data["price8"]=$_REQUEST["martkprice"];
		$data["price9"]=$_REQUEST["myprice"];
		$data["price11"]=$_REQUEST["fangcha"];
		$data["price12"]=$_REQUEST["kucun"];
		$data["price3"]=612;
		
		
		
		$mr=M("price");
		
		if($pid>0){
			if($mr->where("price0=".$pid)->save($data)){
				alert("", 0, "修改成功");
				gourl(U("hotelroom/edithotelprice")."/MenuId/".$MenuId."/rid/".$rid."/pid/".$pid."/PMID/$PMID",1);
			}
			else {
				alert("", 1, "修改失败");
			}
			
		}else {
			$data["price4"]=$rid;
			if($mr->add($data)){
				alert("", 0, "添加成功");
				gourl(U("hotelroom/edithotelprice")."/MenuId/".$MenuId."/rid/".$rid."/pid/".$pid."/PMID/$PMID",1);
			}else{
				alert("", 1, "添加失败");
			}
			
		}

	}
	
}

?>